import React, { useState } from 'react';
import CommonModal from '@/components/CommonModal';
import CommonLoading from '@/components/CommonLoading';
import { Alert, Input, Form, message, Radio } from 'antd';
import { layout1 } from '@/utils/config';
// import { saveOfflineStore } from '@/services/common';
// import { history } from 'umi';
import Iconfont from '@/components/IconFont';
import { Base64 } from 'js-base64';

const content = <div style={{ margin: '10px 0', display: 'flex', flexDirection: 'row', justifyContent: 'space-between' }}>
<span><Iconfont type='icontishicontent' style={{ margin: '3px 3px 0px 8px' }} /></span>
<div>
  <div style={{ marginLeft: 5 }}>1：京东云仓店铺授权只为获取接口和云仓订单获取运单号信息使用，不会同步商品或同步订单。</div>
  <div style={{ marginLeft: 5 }}>2：同一个云仓，如果有多个事业部编码，支持授权多次。输入不同云仓店铺名即可创建多个，输入相同店铺名则在原云仓账号上更新。</div>
  <div style={{ marginLeft: 5 }}>3、订单获取运单号，有3种方式。直接获取运单号、导入云仓运单号、云仓单号匹配。</div>
</div>
</div>

export default ({ visible, handleVisible, handleOk }) => {
  const [form] = Form.useForm();
  const [loading, setLoading] = useState(false);

  // const handleSubmit = async () => {
  //   setLoading(true);
  //   const { storeName, offlineExpressPlatform } = form.getFieldsValue();
  //   const res = await saveOfflineStore({
  //     storeName,
  //     offlineExpressPlatform,
  //     type: 0,
  //   });
  //   setLoading(false);
  //   if (res.success) {
  //     message.success('添加成功！');
  //     history.go(0);
  //   }
  // };

  const onOk = () => {
    form.validateFields().then((val) => {
      // const value = Base64.encode(val)
      // handleOk(value);
      handleOk(val)
    });
  };

  return (
    <CommonModal
      title="编辑名称"
      visible={visible}
      onCancel={() => handleVisible(false)}
      onOk={onOk}
      width="600px"
    >
      <Alert message={content} type="info" style={{marginBottom:'12px'}}/>
      <Form {...layout1} form={form} name="add-offline-store">
        <Form.Item
          name="storeName"
          label="京东云仓店铺名"
          rules={[{ required: true, message: '店铺名不能为空' }, { max: 15, message: '不能超过15个字符' }]}
        >
          <Input placeholder="请输入京东云仓的店铺名" />
        </Form.Item>
      </Form>
      <CommonLoading loading={loading} />
    </CommonModal>
  );
};
